/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// The dropdown wrapper (`<div>`)
.dropup,
.dropdown {
  position: relative;
  background-color: $third-highlight;
  width: 300px;
  text-align: left;
  padding-left: 15px;
  margin: 0 auto;
  border-bottom: 2px solid transparent;
  transition: 0.4s cubic-bezier(0.075, 0.820, 0.165, 1.000);

  &:hover {
    background-color: $fourth-highlight;
    border-bottom: 2px solid $first-highlight;
  }
}

button.dropdown-toggle {
  // Generate the caret (base 64 encoded SVG) and place it on the right hand side
  &::after {
    content:url();
    position: absolute;
    cursor: pointer;
    width: 0;
    height: 0;
  }

  // Prevent the focus on the dropdown toggle when closing dropdowns
  &:focus {
    outline: 0;
  }

  width: 100%;
  text-align: left;

  span {
    width: 85%;
    text-overflow: ellipsis;
    overflow: hidden;
    float: left;
  }
}

.dropup {
  .dropdown-toggle {
    &::after {
      border-top: 0;
      border-bottom: 10px solid;
    }
  }
}

// The dropdown menu
.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  display: none; // none by default, but block on "open" of the menu
  float: left;
  min-width: 40px;
  padding: 0 0;
  margin: 0 0 0; // override default ul
  font-size: 12pt; // Redeclare because nesting can cause inheritance issues
  color: grey;
  text-align: left; // Ensures proper alignment if parent has it changed (e.g., modal footer)
  list-style: none;
  background-clip: padding-box;

  background: $third-highlight;
  border: 1px solid $keyline-highlight;
  border-bottom-right-radius: 5px;
  border-bottom-left-radius: 5px;
  border-top: 2px solid $first-highlight;
  box-shadow: 0 1px 10px 0 rgba(0,0,0,0.10);
  width: 300px;
  text-align: left;
  overflow-x: hidden;
  overflow-y: auto;
  text-overflow: ellipsis;
  max-height: 250px;

  &:active {
    border-bottom: 2px solid transparent;
  }



  // Links, buttons, and more within the dropdown menu
  //
  // `<button>`-specific styles are denoted with `// For <button>s`
  .dropdown-item {
    display: block;
    width: 100%; // For `<button>`s
    padding: 1rem 0;
    clear: both;
    font-weight: 12pt;
    color: lightgray;
    text-align: left; // For `<button>`s
    white-space: nowrap; // prevent links from randomly breaking onto new lines
    background: none; // For `<button>`s
    border: 2px solid transparent; // For `<button>`s
    margin-left:0;

      .action {
        padding: 0 1rem;
      }

      &.action {
            padding-left: 15px;
        &:hover {
          border: 2px solid transparent;
          background-color: $fourth-highlight;
        }
      }

    &.active,
    &:active {
      color: grey;
      text-decoration: none;
      background-color: grey;
    }

    &.disabled,
    &:disabled {
      color: lightgray;
      cursor: true;
      background-color: transparent;
      background-image: none;
    }
  }

}
// Open state for the dropdown
.show {
  // Show the menu
  > .dropdown-menu {
    display: block;
  }

  // Remove the outline when :focus is triggered
  > a {
    outline: 0;
  }
}

// Menu positioning
//
// Add extra class to `.dropdown-menu` to flip the alignment of the dropdown
// menu with the parent.
.dropdown-menu-right {
  right: 0;
  left: auto; // Reset the default from `.dropdown-menu`
}

.dropdown-menu-left {
  right: auto;
  left: 0;
}

// Dropdown section headers
.dropdown-header {
  display: block;
  padding: 0 0;
  margin-bottom: 0; // for use with heading elements
  font-size: 8pt;
  color: darkgray;
  white-space: nowrap; // as with > li > a
}

// Backdrop to catch body clicks on mobile, etc.
.dropdown-backdrop {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 0;
}

// Allow for dropdowns to go bottom up (aka, dropup-menu)
//
// Just add .dropup after the standard .dropdown class and you're set.

.dropup {
  // Different positioning for bottom up menu
  .dropdown-menu {
    top: auto;
    bottom: 100%;
    margin-bottom: 0;
  }
}

//Hover state overrides

.composer {
  button {
    &.action {
      &.dropdown-toggle {
          &:hover {
            border-bottom: 2px solid transparent;
            color: $primary-text;
          }
          &:active {
            border-bottom: 2px solid transparent;
            color: $primary-text;

            ::after {
              transform: rotate(90);
            }
          }

          &:focus {
            border-bottom: 2px solid transparent;
            color: $primary-text;

            ::after {
              transform: rotateX(90);
            }
          }
      }
    }
  }
}
